#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int is_com(char arr1[], char arr2[], size_t sz) {
	int Is = 1;
	for (int i = 0; i < sz; i++) {
		if (arr1[i] != arr2[i]) {
			Is = 0;
		}
	}
	return Is;
}
int counter_clockwise(size_t sz, char arr[],char arr2[]) {
	int is_counter_clockwis = 0;
	for (int i = 0; i < sz-1; i++) {
		char arr1[20] = { 0 };
		for (int j = 0; j < sz; j++) {
			int k = (j + i) % sz;
			arr1[j] = arr[k];
		}
		if (is_com(arr1, arr2,sz)) {
			is_counter_clockwis = 1;
			break;
		}
	}
	return is_counter_clockwis;
}

int main()
{
	char arr[20];
	gets(arr);
	char arr2[20];
	gets(arr2);
	size_t sz = strlen(arr);
	if (counter_clockwise(sz, arr,arr2)) {
		printf("1");
	}
	else {
		printf("0");
	}
	return 0;
}